package com.mark.media.controller.v1;

import com.mark.common.media.constans.WmMediaConstans;
import com.mark.media.apis.NewsControllerApi;
import com.mark.media.service.NewsService;
import com.mark.model.common.dtos.ResponseResult;
import com.mark.model.media.dtos.WmNewsDto;
import com.mark.model.media.dtos.WmNewsPageReqDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description :  java类作用描述
 * @Author :  Markburt
 * @CreateDate :  2020/3/8$ 下午 02:59$
 * @UpdateUser :  Markburt
 * @UpdateDate :  2020/3/8$ 下午 02:59$
 * @UpdateRemark :  Project Build
 * @Version :  1.0
 */
@RestController
@RequestMapping("/api/v1/media/news")
public class NewsController implements NewsControllerApi {


    @Autowired
    private NewsService newsService;


    /**
     *保存
     * @param dto
     * @return
     */
    @Override
    @PostMapping("/submit")
    public ResponseResult submitNews(WmNewsDto dto) {
        return newsService.saveNews(dto, WmMediaConstans.WM_NEWS_SUMMIT_STATUS);
    }


    /***
     *修改
     * @param dto
     * @return
     */
    @Override
    @PostMapping("/save_draft")
    public ResponseResult saveDraftNews(WmNewsDto dto) {
        return newsService.saveNews(dto, WmMediaConstans.WM_NEWS_DRAFT_STATUS);
    }


    /**
     *查询文章列表
     * @param dto
     * @return
     */
    @Override
    @PostMapping("/list")
    public ResponseResult listByUser(WmNewsPageReqDto dto) {
        return newsService.listByUser(dto);
    }


    /**
     *根据当前主键查询文章
     * @param dto
     * @return
     */
    @Override
    @PostMapping("/news")
    public ResponseResult wmNews(WmNewsDto dto) {
        return newsService.findWmNewsById(dto);
    }


    /***
     *根据主键删除文章信息
     * @param dto
     * @return
     */
    @Override
    @PostMapping("/del_news")
    public ResponseResult delNews(WmNewsDto dto) {
        return newsService.delNews(dto);
    }
}
